﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Iacym.Entities;

namespace Iacym.Repository.Mapping
{
    public class PERSONA_IDIOMASMap : EntityTypeConfiguration<PERSONA_IDIOMAS>
    {
        public PERSONA_IDIOMASMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("PERSONA_IDIOMAS");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.IdiomaId).HasColumnName("IdiomaId");
            this.Property(t => t.PersonaId).HasColumnName("PersonaId");

            // Relationships
            this.HasRequired(t => t.IDIOMA)
                .WithMany(t => t.PERSONA_IDIOMAS)
                .HasForeignKey(d => d.IdiomaId);
            this.HasRequired(t => t.PERSONA)
                .WithMany(t => t.PERSONA_IDIOMAS)
                .HasForeignKey(d => d.PersonaId);

        }
    }
}
